#ifndef STATE_H_
#define STATE_H_

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <stdint.h>

#include "Timer.h"
#include "Bug.h"
#include "Square.hh"
#include "Map.hh"
#include "Ant.hh"

extern CacheMap torus;
extern FastSet<unsigned> visited;
extern Map<unsigned> depth_map;


/*
    struct to store current state information
*/
struct State
{
  /*
    Variables
  */
  signed noPlayers;
  double loadtime, turntime;
  unsigned turn;
  unsigned turns;
  std::vector<double> scores;
  bool gameover;
  int64_t seed;


  std::vector<uLocation> myHills, food;
  std::vector<Ant> enemyHills;
  std::vector<uLocation> myAnts;
  std::vector<Ant> enemyAnts;

  Timer timer;

  Map<Square> map;
  Map<Square> map_copy;

  /*
    Functions
  */
  State();
  ~State();

  void setup();
  void reset();
  void restore();


  Square & location(uLocation loc)
  {
    return map.at(loc);
  }

  void makeMove(const uLocation &loc, unsigned direction);

  void updateVisionInformation();
  void updateNeighbourInformation();

};

/// dump state
std::ostream& operator<<(std::ostream &os, const State &state);

/// read state from challenge protocol
std::istream& operator>>(std::istream &is, State &state);


#endif //STATE_H_
